//jshint ignore:start
import legacy from "@vitejs/plugin-legacy";
import vue from "@vitejs/plugin-vue";
import { defineConfig } from "vite";
export default defineConfig({
	base: "./",
	build: {
		outDir: "./yst-en",
		assetsInlineLimit() {
			return true;
		},
		terserOptions: {
			// 清除代码中console和debugger
			compress: {
				drop_console: true,
				drop_debugger: true,
			},
		}
	},
	// publicDir: false,
	plugins: [
		vue({
			template: {
				compilerOptions: {
					isCustomElement: tag => tag.startsWith("swiper"),
				},
			},
		}),
		legacy({
			targets: ">0% and not supports es6-module",
			renderModernChunks: false,
		}),
		{
			name: "autoRemoveCrossOrigin",
			transformIndexHtml: {
				order: "post",
				handler(html) {
					return html.replaceAll("crossorigin", "");
				},
			},
		},
	],
	server: {
		host: true,
		open: true,
		cors: true,
	},
	preview: {
		host: true,
		open: true,
		cors: true,
	},
});
